(bug 37587) Enforce language codes to be html safe
authorNiklas Laxström <niklas.laxstrom@gmail.com>
Thu, 28 Jun 2012 14:52:56 +0000 (14:52 +0000)
committercsteipp <csteipp@wikimedia.org>
Mon, 9 Jul 2012 19:51:56 +0000 (12:51 -0700)
Fixes bug 37587 and many other issues which
might or might not have been reported yet.

Change-Id: I612b90931a0261990bcd294fdb12cfba930c8c2f

languages/Language.php

index b531f2a..4d73acb 100644 (file)
@@ -246,7 +246,11 @@ class Language {
         */
        public static function isValidCode( $code ) {
                return
-                       strcspn( $code, ":/\\\000" ) === strlen( $code )
+                       // People think language codes are html safe, so enforce it.
+                       // Ideally we should only allow a-zA-Z0-9-
+                       // but, .+ and other chars are often used for {{int:}} hacks
+                       // see bugs 37564, 37587, 36938
+                       strcspn( $code, ":/\\\000&<>'\"" ) === strlen( $code )
                        && !preg_match( Title::getTitleInvalidRegex(), $code );
        }